Generate source maps for iOS and Android#9596
Conversation
kidroca
left a comment
There was a problem hiding this comment.
Some notes on the changes here
| "source-map:android": "scripts/source-map.sh android", | ||
| "source-map:ios": "scripts/source-map.sh ios", | ||
| "symbolicate:android": "npx metro-symbolicate index.android.bundle.map", | ||
| "symbolicate:ios": "npx metro-symbolicate index.ios.bundle.packager.map" |
There was a problem hiding this comment.
For some reason iOS only works with the .package.map file - it does not work with the combined map file from the packager and the hermes (hbc) map files (produces null:null:null results)
It could be the stacktrace samples are already decoded partially from crashlytics
| OS_BIN="" | ||
|
|
||
| case "$OSTYPE" in | ||
| darwin*) OS_BIN=osx-bin ;; | ||
| linux*) OS_BIN=linux64-bin ;; | ||
| msys*) OS_BIN=win64-bin ;; | ||
| cygwin*) OS_BIN=win64-bin ;; | ||
| *) error "unknown: $OSTYPE" ;; | ||
| esac | ||
|
|
||
| if [ -z "$OS_BIN" ]; then | ||
| error "Failed to match hermes OS-BIN" | ||
| exit 1; | ||
| fi | ||
|
|
||
| info "" | ||
| info "2. Generating hermes map" | ||
| info "" | ||
| info "Using hermes OS-BIN: '$OS_BIN'" | ||
| info "" | ||
|
|
||
| # In react native 0.69 this path needs to change to NODE_MODULES/react-native/sdks/hermesc/$OS_BIN/hermesc | ||
| "$NODE_MODULES/hermes-engine/$OS_BIN/hermesc" -O -emit-binary -output-source-map -out=index.$PLATFORM.bundle.hbc index.$PLATFORM.bundle |
There was a problem hiding this comment.
This script was created following
- scripts from react native source: https://github.com/facebook/react-native/blob/7d42106d4ce20c644bda4d928fb0abc163580cee/scripts/react-native-xcode.sh#L170-L175
- and this guide here: https://docs.sentry.io/platforms/react-native/manual-setup/hermes/#compile-sourcemaps
It's easier to locate a Hermes cli bin from node_modules vs installing pods and then using the cli from pods
The OSTYPE check is necessary because I suspect this script would be run by both linux and mac users
Otherwise we can just set OS_BIN=osx-bin
| node "$NODE_MODULES/react-native/scripts/compose-source-maps.js" \ | ||
| index.$PLATFORM.bundle.packager.map \ | ||
| index.$PLATFORM.bundle.hbc.map \ | ||
| -o index.$PLATFORM.bundle.map | ||
|
|
There was a problem hiding this comment.
This combines the regular source map (package) file together with the bite code source map file
For some reason we only need the combined source map for Android stack traces while for ios the packager source map is enough
I'm still confirming and finding out why
|
@roryabraham @AndrewGable Perhaps it's better than generating manually |
|
Closing this PR in favor of the alternative: #9641 |
Details
Generate source maps files that can be used together with stack traces from Firebase Crashlytics
and show original code point of failure
Ideally source maps should be generated as part of the build process and then saved
Running
npm run source-map:(ios|android)producesindex.(ios|android).bundle.mapfilenpm run symbolicate:(ios|android))Alternatively source maps can be generated by checking older source in a separate work directory and running the source-map and symobilicate commands over it
Fixed Issues
$ #9293
Tests
Requirements to be able to test:
Test Steps
Generate source maps for the given platform (ios|android) should work
npm run source-map:iosornpm run source-map:androidUse the generated source maps to symbolicate (decode) the stack traces
ios.stacktrace.txtVerify that no errors appear in the JS console
PR Review Checklist
Contributor (PR Author) Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*filesSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)PR Reviewer Checklist
### Fixed Issuessection aboveTestssectionQA stepssectiontoggleReportand notonIconClick).src/languages/*filesSTYLE.md) were followed/** comment above it */displayNamepropertythisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)QA Steps
Screenshots
No App code changes, only tools added
Source mapping script running